<template>
  <view class="container">
    <!-- 表单区域 -->
    <view class="form-section">
      <!-- 设备信息 -->
      <view class="form-group">
        <view class="form-title">设备信息</view>
        <view class="form-item">
          <text class="label">设备名称</text>
          <text class="value">{{ sbInfo.sbmc }}</text>
        </view>
        <view class="form-item">
          <text class="label">设备编号</text>
          <text class="value">{{ sbInfo.sbbh }}</text>
        </view>
        <view class="form-item">
          <text class="label">所在位置</text>
          <text class="value">{{ sbInfo.azdd }}</text>
        </view>
        <view class="form-item">
          <text class="label">保养年月</text>
          <text class="value">{{ year }}-{{ month.length === 1 ? '0' + month : month }}</text>
        </view>
        <view class="form-item">
          <text class="label">是否合格</text>
          <view class="isQualified">
            <view class="value"> {{ isQualified ? '是' : '否' }}</view>
            <up-switch :disabled="isDisabled" :size="14" v-model="isQualified" @change="qualifiedChange"></up-switch>
          </view>
        </view>
        <view class="form-item">
          <text class="label">审批进度</text>
          <view class="isQualified">
            <view class="value"> {{ currentStatusText }}</view>
            <u-icon name="/static/images/jump.png" :size="16" @tap="showApproveHistory"/>
          </view>
        </view>
        <view class="form-item" v-if="maintainerSignature != null">
          <text class="label">保养者</text>
          <template v-for="(item,index) in maintainerSignatureArray" :key="index">
            <image class="signaturePic" :src="showPic(item)" mode="scaleToFill"/>
          </template>
        </view>
        <view class="form-item" v-if="maintenanceManagerSignature != null">
          <text class="label">保养负责人</text>
          <image class="signaturePic" :src="showPic(maintenanceManagerSignature)" mode="aspectFill"/>
        </view>
        <view class="form-item" v-if="operatorSignature != null">
          <text class="label">操作者</text>
          <image class="signaturePic" :src="showPic(operatorSignature)" mode="aspectFill"/>
        </view>
        <view class="form-item" v-if="eqptOprSignature != null">
          <text class="label">设备员</text>
          <image class="signaturePic" :src="showPic(eqptOprSignature)" mode="aspectFill"/>
        </view>
        <view class="form-item" v-if="acptAdminSignature != null">
          <text class="label">验收管理员</text>
          <image class="signaturePic" :src="showPic(acptAdminSignature)" mode="aspectFill"/>
        </view>
        <view class="form-item" v-if="acptPicSignature != null">
          <text class="label">验收负责人</text>
          <image class="signaturePic" :src="showPic(acptPicSignature)" mode="aspectFill"/>
        </view>
      </view>

      <!-- 保养项目列表 -->
      <view class="form-group">
        <view class="form-header">
          <view class="form-title">保养项目</view>
          <view class="quick-action" v-if="!isDisabled" :class="{ 'is-marked': isAllMarked }" @tap="toggleMarkAll">
            <text class="action-text">{{ isAllMarked ? '一键取消' : '一键合格' }}</text>
          </view>
        </view>
        <view class="check-list">

          <view v-for="(value,key,index) in maintenanceLevelTwoDetailTwoCycleList" :key="index">
            <view>
              <text class="form-title"> {{ key }}</text>
              <view class="check-item" v-for="(item) in value" :key="item.id" slot="body">

                <view class="check-header">
                  <text class="label">工序内容</text>
                  <text class="check-name">{{ item.maintenancecontent }}
                    <text v-if="todoSum==0">
                      [{{ item.status === '1' ? '正常' : '异常' }}][{{
                        item.worktype2 === '1' ? '电气' : ''
                      }}{{ item.worktype === '1' ? '机械' : '' }}]
                    </text>
                  </text>
                  <!--                  <u-icon name="/static/images/info.png" :size="16" @tap="showEligibility(item.eligibility)"/>-->
                </view>

                <view class="check-header">
                  <text class="label">合格标准</text>
                  <text class="check-name">{{ item.eligibility }}</text>
                  <!--                  <text class="check-required" v-if="item.required">*</text>-->
                </view>

                <view class="check-options" v-if="todoSum>0">
                  <view :class="'option ' + (item.status === '1' ? 'active' : '')"
                        @tap="onOptionSelect(key,item,'1')">正常
                  </view>
                  <view :class="'option ' + (item.status === '0' ? 'active' : '')"
                        @tap="onOptionSelect(key,item,'0')">异常
                  </view>
                </view>
                <view class="check-options" v-if="todoSum>0">
                  <view :class="'option ' + (item.worktype === '1' ? 'active' : '')"
                        @tap="workTypeSelect(key,item)">机械
                  </view>
                  <view :class="'option ' + (item.worktype2 === '1' ? 'active' : '')"
                        @tap="workType2Select(key,item)">电气
                  </view>
                </view>

                <!-- 异常情况下显示描述输入框和照片上传 -->
                <view class="abnormal-content">
                  <textarea v-if="item.status === '0'"
                            :disabled="isDisabled || (item.feedbackfilepathone !== '' && item.feedbackfilepathone !== null) "
                            class="abnormal-desc" placeholder="请描述遇到的问题或者保养情况"
                            v-model="item.existingproblem"></textarea>

                  <!-- 添加照片上传区域 -->
                  <view class="upload-images">
                    <view class="image-list">
                      <view class="image-item" v-for="(img, imgIndex) in (item.fileList || [])" :key="imgIndex">
                        <image :src="showPic(img.filePath)" mode="aspectFill"
                               @tap="previewImage(item.fileList, imgIndex)"/>
                        <view
                            v-if="!isDisabled && (item.feedbackfilepathone === ''||item.feedbackfilepathone === null) "
                            class="delete-btn" @tap.stop="deleteImage(item.fileList, imgIndex)">×
                        </view>
                      </view>
                      <view class="upload-btn" :disabled="isDisabled" @tap="chooseImage(key,item.id)"
                            v-if="!isDisabled && (item.fileList === undefined || item.fileList.length < 3)&& (item.feedbackfilepathone === '' || item.feedbackfilepathone === null) ">
                        <text class="upload-icon">+</text>
                        <text class="upload-text">上传照片</text>
                        <text class="upload-desc">{{ item.fileList ? (3 - item.fileList.length) : 3 }}张
                        </text>
                      </view>
                    </view>
                  </view>
                </view>

                <!--                <view class="signatureBox" style="display: flex;justify-content: space-between;align-items: center">
                                  <text class="label" >保养人签字</text>
                                  <image class="signaturePic" style="width: 120rpx;height: 60rpx" :src="showPic(item.feedbackfilepathone)" mode="aspectFill"/>
                                </view>-->

                <view class="check-header">
                  <text class="label">保养人</text>
                  <text class="check-name">{{ item.feedbackBy }}</text>
                </view>

              </view>
            </view>
          </view>
        </view>
      </view>

      <!-- 图片上传区域 -->
      <view class="form-group">
        <view class="form-title">现场照片</view>
        <view class="upload-section">
          <view class="image-list">
            <view class="image-item" v-for="(item, index) in byjhFileList" :key="index">
              <image :src="showPic(item.filePath)" mode="aspectFill" @tap="previewImage(byjhFileList,index)"/>
              <view v-if="!isDisabled && (item.createPeopleId === userId || item.createPeopleId === undefined)"
                    class="delete-btn" @tap.stop="deleteImage(byjhFileList,index)">×
              </view>
            </view>
            <view :disabled="isDisabled" class="upload-btn" @tap="chooseByImage()" v-if="!isDisabled">
              <text class="upload-icon">+</text>
              <text class="upload-text">上传照片</text>
            </view>
          </view>
        </view>
      </view>

      <!-- 备注信息 -->
      <view class="form-group">
        <view class="form-title">备注信息</view>
        <textarea :disabled="isDisabled" class="remarks" placeholder="请输入备注信息（选填）"
                  v-model="byjhInfo.remarks"></textarea>
      </view>
    </view>

    <!-- 提交按钮 -->
    <view class="footer-submit">
      <button v-if="byzConfirmButtonVisitable" :disabled="isDoubleClickDisabled" @tap="submitByzConfirm">
        保养者反馈
      </button>
      <button class="revoke" v-if="byzRevokeButtonVisitable" :disabled="isDoubleClickDisabled" @tap="revokeByzConfirm">
        保养者撤销反馈
      </button>
      <button v-if="byfzrConfirmButtonVisitable" :disabled="isDoubleClickDisabled" @tap="submitByfzrConfirm">
        保养负责人审核
      </button>
      <button class="revoke" v-if="byfzrRevokeButtonVisitable" :disabled="isDoubleClickDisabled" @tap="revokeByfzrConfirm">
        保养负责人撤销审核
      </button>
      <button v-if="czzConfirmButtonVisitable" :disabled="isDoubleClickDisabled" @tap="submitCzzConfirm">
        操作者审核
      </button>
      <button class="revoke" v-if="czzRevokeButtonVisitable" :disabled="isDoubleClickDisabled" @tap="revokeCzzConfirm">
        操作者撤销审核
      </button>
      <button v-if="sbyConfirmButtonVisitable" :disabled="isDoubleClickDisabled" @tap="submitSbyConfirm">
        设备员审核
      </button>
      <button class="revoke" v-if="sbyRevokeButtonVisitable" :disabled="isDoubleClickDisabled" @tap="revokeSbyConfirm">
        设备员撤销审核
      </button>
      <button v-if="ysglyConfirmButtonVisitable" :disabled="isDoubleClickDisabled" @tap="submitYsglyConfirm">
        验收管理员审核
      </button>
      <button class="revoke" v-if="ysglyRevokeButtonVisitable" :disabled="isDoubleClickDisabled" @tap="revokeYsglyConfirm">
        验收管理员撤销审核
      </button>
      <button v-if="ysfzrConfirmButtonVisitable" :disabled="isDoubleClickDisabled" @tap="submitYsfzrConfirm">
        验收负责人审核
      </button>
      <button class="revoke" v-if="ysfzrRevokeButtonVisitable" :disabled="isDoubleClickDisabled" @tap="revokeYsfzrConfirm">
        验收负责人撤销审核
      </button>
    </view>

  </view>
</template>

<script>

import dayjs from "dayjs/esm";
import {bzzPermission, Role, roleExists, sbkPermission, sbyPermission} from "../../../common/permission";

export default {
  onLoad: function (option) {
    this.year = option.year;
    this.month = option.month;
    this.equipmentId = option.equipmentId;
    this.planId = option.id;
    this.baseUrl = this.$commonUnits.baseUrl;
    this.userId = this.$commonUnits.getUserId();
    this.userPic = uni.getStorageSync('user_pic');
    //获取设备基本信息
    this.getEquipmentInfo();
    //获取设备保养项目
    this.getMaintenanceLevelTwoDetail();
    this.getByjh();
    this.getByjhFileList();
  },
  data() {
    return {
      baseUrl: "",
      isDisabled: false,//全局只读控制
      isDoubleClickDisabled: false,//双击防抖
      year: '',
      month: '',
      equipmentId: '',
      planId: '',
      isQualified: true,
      sbInfo: {
        sbmc: "",
        sbbh: "",
        azdd: ""
      },
      eqptOprSignature: "",
      maintainerSignature: "",
      maintainerSignatureArray: [],
      maintenanceManagerSignature: "",
      operatorSignature: "",
      acptAdminSignature: "",
      acptPicSignature: "",
      todoSum: "",
      maintenanceLevelTwoDetailList: [],
      maintenanceLevelTwoDetailTwoCycleList: [],
      clonedMaintenanceLevelTwoDetailList: [],
      userPic: "",
      userId: "",
      byjhInfo: {},
      byjhFileList: [],
      byzConfirmButtonVisitable: false,
      byzRevokeButtonVisitable: false,
      byfzrConfirmButtonVisitable: false,
      byfzrRevokeButtonVisitable: false,
      czzConfirmButtonVisitable: false,
      czzRevokeButtonVisitable: false,
      sbyConfirmButtonVisitable: false,
      sbyRevokeButtonVisitable: false,
      ysglyConfirmButtonVisitable: false,
      ysglyRevokeButtonVisitable: false,
      ysfzrConfirmButtonVisitable: false,
      ysfzrRevokeButtonVisitable: false,
      submitData: [],
      isAllMarked: false, // 添加 isAllMarked 字段
      currentStatusText: "",// 列表显示当前状态文字
      remarkLabel: "",// TODO 审批/撤销备注标题 移入弹窗中输入
      approveRemarks: "",// TODO 保养审批备注 移入弹窗中输入
      planUserPicSet: {},
      planUserIdSet: {},
    };
  },
  watch: {},
  methods: {
    // 获取设备基本信息
    getEquipmentInfo() {
      this.$commonUnits.postRequest('sbby.zcglsbtzbiz.getZcglSbtzById.mobile', {id: this.equipmentId}).then(item => {
        this.sbInfo = item.res[0];
      })
    },
    getMaintenanceLevelTwoDetail() {
      this.$commonUnits.postRequest('sbby.maintenancemobilebiz.getMaintenanceLevelTwoDetail.mobile',
          {
            sbid: this.equipmentId,
            year: this.year,
            month: this.month
          }
      ).then(item => {
        this.maintenanceLevelTwoDetailList = item.res.list;
        this.planUserPicSet = new Set();
        this.planUserIdSet = new Set();
        for (const item of this.maintenanceLevelTwoDetailList) {
          this.planUserPicSet.add(item.feedbackfilepathone);
          if (!this.$commonUnits.isBankStr(item.feedbackBy))
            this.planUserIdSet.add(item.feedbackBy);
        }
        this.maintainerSignature = item.res.maintainerSignature; //保养者签名
        if (this.maintainerSignature !== null)
          this.maintainerSignatureArray = this.maintainerSignature.split(',');
        this.maintenanceManagerSignature = item.res.maintenanceManagerSignature; //保养负责人签名
        this.operatorSignature = item.res.operatorSignature; //操作者签名
        this.eqptOprSignature = item.res.eqptOprSignature; //设备员签名
        this.acptAdminSignature = item.res.acptAdminSignature; //验收管理员签名
        this.acptPicSignature = item.res.acptPicSignature; //验收负责人签名
        this.todoSum = item.res.todoSum; //待保养数量

        //保养人反馈（只要保养项目没有全部签字提交）
        if (this.maintainerSignature === null || (this.maintenanceManagerSignature === null && this.todoSum > 0)) {
          //验证角色/权限
          if (bzzPermission(this.sbInfo.whichworhshop) && roleExists(Role.bzz))
            this.byzConfirmButtonVisitable = true;
          this.currentStatusText = "待保养人反馈";
          // 部分提交的情况下 可以撤销自己保养的项目
          if (this.maintainerSignature != null) {
            if (this.maintainerSignature.split(',').find(item => item === this.userPic) === this.userPic) {
              if (bzzPermission(this.sbInfo.whichworhshop) && roleExists(Role.bzz))
                this.byzRevokeButtonVisitable = true;
            }
          }
        }

        //待保养负责人审核，保养可撤销（只要本人提交过部分保养项目 就可以进行撤销）
        if (this.maintainerSignature !== null && this.maintenanceManagerSignature === null && this.todoSum === 0) {
          this.currentStatusText = "待保养负责人审核";
          // 只要有自己的保养签名就可以进行撤销动作
          if (this.maintainerSignature.split(',').find(item => item === this.userPic) === this.userPic) {
            //保养者撤销按钮
            if (bzzPermission(this.sbInfo.whichworhshop) && roleExists(Role.bzz))
              this.byzRevokeButtonVisitable = true;
          }
          //保养负责人没有权限  只有角色控制
          if (roleExists(Role.gdz))
            this.byfzrConfirmButtonVisitable = true;
          this.isDisabled = true; // 保养内容全面禁用
        }

        //保养负责人待撤销（保养负责人签名是登录人的,操作人未签）
        if (this.maintenanceManagerSignature === this.userPic && this.operatorSignature === null) {
          if (roleExists(Role.gdz))
            this.byfzrRevokeButtonVisitable = true;
          this.isDisabled = true;
          this.currentStatusText = "待操作者审核";
        }

        //操作者待审核
        if (this.maintenanceManagerSignature !== null && this.operatorSignature === null) {
          if (bzzPermission(this.sbInfo.whichworhshop) && roleExists(Role.bzz))
            this.czzConfirmButtonVisitable = true;
          this.isDisabled = true; // 保养内容全面禁用
          this.currentStatusText = "待操作者审核";
        }

        //操作者待撤销（操作者签名是登录人的,设备员未签）
        if (this.operatorSignature === this.userPic && this.eqptOprSignature === null) {
          if (bzzPermission(this.sbInfo.whichworhshop) && roleExists(Role.bzz))
            this.czzRevokeButtonVisitable = true;
          this.isDisabled = true;
          this.currentStatusText = "待设备员审核";
        }

        //设备员待审核
        if (this.operatorSignature !== null && this.eqptOprSignature === null) {
          if (sbyPermission(this.sbInfo.whichworhshop) && roleExists(Role.sybmsby))
            this.sbyConfirmButtonVisitable = true;
          this.isDisabled = true; // 保养内容全面禁用
          this.currentStatusText = "待设备员审核";
        }

        //设备员待撤销（设备员签名是登录人的,验收管理员未签）
        if (this.eqptOprSignature === this.userPic && this.acptAdminSignature === null) {
          if (sbyPermission(this.sbInfo.whichworhshop) && roleExists(Role.sybmsby))
            this.sbyRevokeButtonVisitable = true;
          this.isDisabled = true;
          this.currentStatusText = "待验收管理员审核";
        }

        //验收管理员待审核
        if (this.eqptOprSignature !== null && this.acptAdminSignature === null) {
          if (sbkPermission(this.sbInfo.whichworhshop) && roleExists(Role.sbk))
            this.ysglyConfirmButtonVisitable = true;
          this.isDisabled = true; // 保养内容全面禁用
          this.currentStatusText = "待验收管理员审核";
        }

        //验收管理员待撤销（验收管理员签名是登录人的,验收负责人未签）
        if (this.acptAdminSignature === this.userPic && this.acptPicSignature === null) {
          if (sbkPermission(this.sbInfo.whichworhshop) && roleExists(Role.sbk))
            this.ysglyRevokeButtonVisitable = true;
          this.isDisabled = true;
          this.currentStatusText = "待验收负责人审核";
        }

        //验收管理员待审核
        if (this.acptAdminSignature !== null && this.acptPicSignature === null) {
          if (sbkPermission(this.sbInfo.whichworhshop) && roleExists(Role.sbk))
            this.ysfzrConfirmButtonVisitable = true;
          this.isDisabled = true; // 保养内容全面禁用
          this.currentStatusText = "待验收负责人审核";
        }

        //设备员待撤销（设备员签名是登录人的,验收管理员未签）
        if (this.acptPicSignature === this.userPic) {
          if (sbkPermission(this.sbInfo.whichworhshop) && roleExists(Role.sbk))
            this.ysfzrRevokeButtonVisitable = true;
          this.isDisabled = true;
          this.currentStatusText = "验收负责人已审核";
        }

        if (this.acptPicSignature !== null) {
          this.isDisabled = true;
        }
        //处理数据 提取保养项目 作为分组key
        this.maintenanceLevelTwoDetailTwoCycleList =
            this.$commonUnits.groupBy(this.maintenanceLevelTwoDetailList, 'program');
        //克隆一份  用来提交前比较，是否至少填写了一项保养项
        this.clonedMaintenanceLevelTwoDetailList = this.$commonUnits.deepClone(this.maintenanceLevelTwoDetailList);
      })
    },
    getByjh() {
      this.$commonUnits.postRequest('sbby.maintenancemobilebiz.getByjhById.mobile', {id: this.planId}).then(item => {
        this.byjhInfo = item.res;
        this.isQualified = this.byjhInfo.qualified === '1';
      })
    },
    getByjhFileList() {
      this.$commonUnits.postRequest('sbby.maintenancemobilebiz.getFilesById.mobile', {id: this.planId}).then(item => {
        this.byjhFileList = item.res;
      })
    },
    qualifiedChange(item) {
      if (item) {
        this.byjhInfo.qualified = '1';
        this.isQualified = true;
      } else {
        this.byjhInfo.qualified = '0';
        this.isQualified = false;
      }
    },
    showApproveHistory() {
      uni.navigateTo({url: `/pages/maintenance/level1/approveHistory?id=${this.planId}`});
    },
    //显示检验标准
    showEligibility(item) {
      uni.showModal({
        title: '合格标准',
        content: item,
        showCancel: false,
        success: (res) => {

        }
      });
    },
    // 选择检查结果
    onOptionSelect(key, item, status) {
      //只读状态
      if (this.isDisabled || !this.$commonUnits.isBankStr(item.feedbackfilepathone)) {
        return 0;
      }
      //找到操作字段并赋值
      const index = this.maintenanceLevelTwoDetailTwoCycleList[key].findIndex((item1) => item1.id === item.id);
      if (index > -1) {
        this.maintenanceLevelTwoDetailTwoCycleList[key][index].status = status;
        //选择任意一个就认为是保养了
        this.maintenanceLevelTwoDetailTwoCycleList[key][index].whethermaintained = '1';
        // 签名照片
        this.maintenanceLevelTwoDetailTwoCycleList[key][index].feedbackfilepathoneTemp = this.userPic;
      }
    },
    // 选择机械
    workTypeSelect(key, item) {
      //只读状态
      if (this.isDisabled || !this.$commonUnits.isBankStr(item.feedbackfilepathone)) {
        return 0;
      }
      //找到操作字段并赋值
      const index = this.maintenanceLevelTwoDetailTwoCycleList[key].findIndex((item1) => item1.id === item.id);
      if (index > -1) {
        let worktype = this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype;
        if (worktype === '1')
          this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype = '0';
        if (worktype === null || worktype === '0') {
          this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype = '1';
          this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype2 = '0';
        }
      }
    },

    // 选择电气
    workType2Select(key, item) {
      //只读状态
      if (this.isDisabled || !this.$commonUnits.isBankStr(item.feedbackfilepathone)) {
        return 0;
      }
      //找到操作字段并赋值
      const index = this.maintenanceLevelTwoDetailTwoCycleList[key].findIndex((item1) => item1.id === item.id);
      if (index > -1) {
        let worktype2 = this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype2;
        if (worktype2 === '1')
          this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype2 = '0';
        if (worktype2 === null || worktype2 === '0') {
          this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype2 = '1';
          this.maintenanceLevelTwoDetailTwoCycleList[key][index].worktype = '0';
        }
      }
    },
    showPic(filePath) {
      if (this.$commonUnits.isBankStr(filePath))
        return
      if (filePath.indexOf('/tmp/') !== -1 || filePath.indexOf('wxfile://tmp_') !== -1)
        return filePath;
      else
          //不是临时照片，需要拼上baseurl
        return this.baseUrl + filePath.replace(/\\/g, '/');
    },

    // 选择图片
    chooseImage(key, id) {
      if (this.isDisabled)
        return
      const item = this.maintenanceLevelTwoDetailTwoCycleList[key].find(item => item.id === id);
      if (!item) return;

      const maxCount = 3 - (item.fileList?.length || 0);
      uni.chooseImage({
        count: maxCount,
        sizeType: ['compressed'],
        sourceType: ['album', 'camera'],
        success: (res) => {
          item.fileList = item.fileList === undefined ? [] : item.fileList;
          for (let tempFilePath in res.tempFilePaths) {
            item.fileList.push({filePath: res.tempFilePaths[tempFilePath]});
          }
        }
      });
    },

    // 选择图片
    chooseByImage() {
      if (this.isDisabled)
        return
      const maxCount = 3 - (this.byjhFileList?.length || 0);
      uni.chooseImage({
        count: maxCount,
        sizeType: ['compressed'],
        sourceType: ['album', 'camera'],
        success: (res) => {
          this.byjhFileList = this.byjhFileList === undefined ? [] : this.byjhFileList;
          for (let tempFilePath in res.tempFilePaths) {
            this.byjhFileList.push({filePath: res.tempFilePaths[tempFilePath]});
          }
        }
      });
    },

    // 预览图片
    previewImage(urls, current) {
      let onlyUrls = '';
      // 服务器图片要拼上baseurl
      if (urls[0].filePath.indexOf('/tmp/') === -1 && urls[0].filePath.indexOf('wxfile://tmp_') === -1) {
        onlyUrls = urls.map(item => {
          return this.baseUrl + item.filePath.replace(/\\/g, '/');
        });
      } else {
        onlyUrls = urls.map(item => {
          return item.filePath.replace(/\\/g, '/');
        });
      }
      console.log("预览", onlyUrls, current)
      uni.previewImage({
        urls: onlyUrls,
        current: onlyUrls[current]
      });
    },

    // 删除图片
    deleteImage(fileList, imageIndex) {
      if (this.isDisabled)
        return
      fileList.splice(imageIndex, 1);
    },

    // 切换标记状态
    toggleMarkAll() {
      if (!this.isAllMarked) {
        this.markAllNormal();
      } else {
        this.unmarkAll();
      }
    },

    // 一键合格
    markAllNormal() {
      uni.showModal({
        title: '确认提示',
        content: '确定将所有检查项标记为正常吗？',
        success: (res) => {
          if (res.confirm) {
            for (const key in this.maintenanceLevelTwoDetailTwoCycleList) {
              this.maintenanceLevelTwoDetailTwoCycleList[key].forEach(item => {
                if (!this.$commonUnits.isBankStr(item.feedbackfilepathone))
                  return 0;
                else {
                  item.whethermaintained = '1';
                  item.status = '1';
                  item.feedbackfilepathoneTemp = this.userPic;
                  // item.existingproblem = '';
                }
              })
            }
            uni.showToast({
              title: '全部标记为正常',
              icon: 'success'
            });
            this.isAllMarked = !this.isAllMarked;
          }
        }
      });
    },

    //图片转换成base64
    readFileAsBase64(filePath) {
      return new Promise((resolve, reject) => {
        const fs = uni.getFileSystemManager();
        fs.readFile({
          filePath,
          encoding: 'base64',
          success: res => resolve(res.data),
          fail: err => reject(err)
        });
      });
    },

    // 取消所有标记
    unmarkAll() {
      uni.showModal({
        title: '确认提示',
        content: '确定取消所有检查项的标记吗？',
        success: (res) => {
          if (res.confirm) {
            for (const key in this.maintenanceLevelTwoDetailTwoCycleList) {
              this.maintenanceLevelTwoDetailTwoCycleList[key].forEach(item => {
                if (!this.$commonUnits.isBankStr(item.feedbackfilepathone))
                  return 0;
                else {
                  item.whethermaintained = '';
                  item.status = '';
                  item.feedbackfilepathoneTemp = '';
                  // item.existingproblem = '';
                }
              })
            }
            uni.showToast({
              title: '已取消所有标记',
              icon: 'success'
            });
            this.isAllMarked = !this.isAllMarked;
          }
        }
      });
    },

    //提交前确认当前登录用户有无数字签名
    async confirmUserPic() {
      var userPic = '';
      //调用接口获取用户数字签名
      await this.$commonUnits.postRequest('sbby.userinformationbiz.getUserPicFilePathByUserId.mobile', {userid: this.userId}).then(item => {
        //将 当前用户的数字签名 保存到 user_pic
        userPic = item.res.FILE_PATH;
      })
      if (this.$commonUnits.isBankStr(userPic)) {
        uni.showToast({
          title: '用户未配置签名',
          icon: 'error',
          duration: 2000,
          success: () => {

          }
        });
        return false;
      }
      return true;
    },

    async submitByzConfirm() {
      let result = 0;
      let toMaintenanceNum = 0;
      let clonedToMaintenanceNum = 0;
      // console.log(this.clonedMaintenanceLevelTwoDetailList,this.maintenanceLevelTwoDetailTwoCycleList);
      this.clonedMaintenanceLevelTwoDetailList.forEach(item => {
        if (this.$commonUnits.stringIsBlank(item.whethermaintained) || item.whethermaintained === '0') {
          clonedToMaintenanceNum++;
        }
      })
      //提交前检查(至少填写一项内容)
      for (const key in this.maintenanceLevelTwoDetailTwoCycleList) {
        this.maintenanceLevelTwoDetailTwoCycleList[key].forEach(item => {
          //统计未检查项
          if (this.$commonUnits.stringIsBlank(item.whethermaintained) || item.whethermaintained === '0') {
            toMaintenanceNum++;
          }

        })
      }
      if (toMaintenanceNum === clonedToMaintenanceNum) {
        uni.showToast({
          title: '请至少填写一项检查项结果',
          icon: 'none'
        });
        result = 1;
      }
      if (result === 1) {
        return 0;
      } else {
        //确认当前用户有无签名
        if (await this.confirmUserPic()) {
          //防抖。重复提交
          this.isDoubleClickDisabled = true;
          //处理数据，为后端提供便利
          //准备feedback表数据
          this.submitData = [];

          //用于返回list页面显示保养人
          this.planUserIdSet.add(this.userId);
          let feedbackBy = '';
          if (this.planUserIdSet.size > 1) {
            feedbackBy = [...this.planUserIdSet].join(',');
          }
          if (this.planUserIdSet.size === 1) {
            feedbackBy = [...this.planUserIdSet][0];
          }
          //console.log('feedbackBy',feedbackBy);

          for (const key in this.maintenanceLevelTwoDetailTwoCycleList) {
            for (const item of this.maintenanceLevelTwoDetailTwoCycleList[key]) {
              //新保养的项目需要
              if (item.feedbackfilepathoneTemp !== undefined) {
                item.feedbackfilepathone = item.feedbackfilepathoneTemp;
                item.isNew = '1';
              }
              //如果是正常项，提交的时候不要去提交异常内容文本
              this.submitData.push(item);
              //图片附件
              if (item.fileList && item.fileList.length > 0) {
                item.fileList = await Promise.all(
                    item.fileList.map(async (fileItem) => {
                      if (fileItem.fileId === undefined) {
                        const base64 = await this.readFileAsBase64(fileItem.filePath);
                        return {
                          ...fileItem,
                          base64, // 添加 base64 字段或替换原字段
                        };
                      } else {
                        return {
                          ...fileItem
                        };
                      }
                    })
                );
              }
            }
          }
          //单据附件
          if (this.byjhFileList && this.byjhFileList.length > 0) {
            this.byjhFileList = await Promise.all(
                this.byjhFileList.map(async (fileItem) => {
                  if (fileItem.fileId === undefined) {
                    const base64 = await this.readFileAsBase64(fileItem.filePath);
                    return {
                      ...fileItem,
                      base64, // 添加 base64 字段或替换原字段
                    };
                  } else {
                    return {
                      ...fileItem
                    };
                  }
                })
            );
          }
          //console.log(this.submitData);
          //this.equipmentId this.userPic this.userId this.planId this.year this.month byjhInfo.remarks byjhInfo.qualified byjhFileList submitData
          this.$commonUnits.postRequest("sbby.maintenancemobilebiz.submitMantenanceTwoDetail.mobile",
              {
                userPic: this.userPic,
                equipmentId: this.equipmentId,
                userId: this.userId,
                planId: this.planId,
                remarks: this.byjhInfo.remarks,
                qualified: this.byjhInfo.qualified,
                year: this.year,
                month: this.month,
                details: this.submitData,
              }).then(item => {
            uni.hideLoading();
            if (item.res === 3) {
              uni.showToast({
                title: '审批进度已变化',
                icon: 'error',
                duration: 2000,
                success: () => {
                  // 修改一下列表状态显示
                  uni.$emit('updateListData',
                      {
                        planId: this.planId,
                        maintainerSignature: this.userPic,
                        maintenanceManagerSignature: null,
                        todoSum: 0,
                        feedbackBy: feedbackBy
                      });
                }
              });
            }
            if (item.res === 1) {
              uni.showToast({
                title: '提交成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  //上传 单据附件 全删全插
                  this.$commonUnits.postRequest("sbby.maintenancemobilebiz.savefile.mobile",
                      {
                        equipmentId: this.equipmentId,
                        userId: this.userId,
                        planId: this.planId,
                        year: this.year,
                        month: this.month,
                        level: '2',
                        detail: {fileList: this.byjhFileList},
                      })
                  // 延迟返回上一页
                  setTimeout(() => {
                    //console.log('submitData',this.submitData)
                    let noCommitData = this.submitData.filter(item => {
                      return item.whethermaintained === '0'
                    });
                    //console.log(noCommitData);
                    if (noCommitData.length > 0) {
                      // 修改一下列表状态显示
                      uni.$emit('updateListData',
                          {
                            planId: this.planId,
                            maintainerSignature: this.userPic,
                            maintenanceManagerSignature: null,
                            todoSum: noCommitData.length,
                            feedbackBy: feedbackBy
                          });
                    } else {
                      // 修改一下列表状态显示
                      uni.$emit('updateListData',
                          {
                            planId: this.planId,
                            maintainerSignature: this.userPic,
                            maintenanceManagerSignature: null,
                            todoSum: 0,
                            feedbackBy: feedbackBy
                          });
                    }
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                }
              });
            }
          })
        }
      }
    },

    revokeByzConfirm() {
      this.isDoubleClickDisabled = true;

      //获取撤销后剩下的签名信息
      this.planUserPicSet.delete(this.userPic);
      let planUserPic = '';
      if (this.planUserPicSet.size > 1) {
        planUserPic = [...this.planUserPicSet].join(',');
      }
      if (this.planUserPicSet.size === 1) {
        planUserPic = [...this.planUserPicSet][0];
      }
      //用于返回list页面显示保养人
      // console.log('this.userId',this.userId);
      this.planUserIdSet.delete(this.userId);
      let feedbackBy = null;
      if (this.planUserIdSet.size > 1) {
        feedbackBy = [...this.planUserIdSet].join(',');
      }
      if (this.planUserIdSet.size === 1) {
        feedbackBy = [...this.planUserIdSet][0];
      }
      // console.log('feedbackBy',feedbackBy);

      //获取撤销后剩下的保养人userid(feedbackBy) 修改list页面内容

      uni.showModal({
        title: '撤销保养者反馈',
        // content: '请填写撤销原因',
        placeholderText: '请填写撤销原因',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.revokeByzConfirm.mobile", {
              planId: this.planId,
              equipmentId: this.equipmentId,
              year: this.year,
              month: this.month,
              userId: this.userId,
              // remarks: this.approveRemarks
              remarks: res.content,
              userPic: this.userPic,
              planUserPic: planUserPic, //当前计划撤回后还剩下的签名
            }).then(item => {
              uni.showToast({
                title: '撤销成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示 撤销就是待保养
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          maintainerSignature: this.userPic,
                          maintenanceManagerSignature: null,
                          todoSum: 1,
                          feedbackBy: feedbackBy
                        });

                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },

              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },

    submitByfzrConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '保养负责人审核确认',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.submitByfzrConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              userPic: this.userPic,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '审核成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          maintenanceManagerSignature: this.userPic,
                          operatorSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },

    revokeByfzrConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '撤销保养负责人审核',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.revokeByfzrConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '撤销成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          maintainerSignature: this.userPic,
                          maintenanceManagerSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },

    //操作者审核确认
    submitCzzConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '操作者审核确认',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.submitCzzConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              userPic: this.userPic,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '审核成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          operatorSignature: this.userPic,
                          eqptOprSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },

    revokeCzzConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '撤销操作者审核',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.revokeCzzConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '撤销成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          operatorSignature: this.userPic,
                          eqptOprSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },

    submitSbyConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '设备员审核确认',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.submitSbyConfirm2.mobile", {
              planId: this.planId,
              userId: this.userId,
              userPic: this.userPic,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '审核成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          eqptOprSignature: this.userPic,
                          acptAdminSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },
    revokeSbyConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '撤销设备员审核',
        // content: '请填写撤销原因',
        placeholderText: '请填写撤销原因',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.revokeSbyConfirm2.mobile", {
              planId: this.planId,
              userId: this.userId,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '撤销成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          operatorSignature: this.userPic,
                          eqptOprSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },

              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },
    submitYsglyConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '验收管理员审核确认',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.submitYsglyConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              userPic: this.userPic,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '审核成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          acptAdminSignature: this.userPic,
                          acptPicSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },
    revokeYsglyConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '撤销验收管理员审核',
        placeholderText: '请填写撤销原因',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.revokeYsglyConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '撤销成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          eqptOprSignature: this.userPic,
                          acptAdminSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },
    submitYsfzrConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '验收负责人审核确认',
        placeholderText: '请填写审核备注',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.submitYsfzrConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              userPic: this.userPic,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '审核成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          acptAdminSignature: this.userPic,
                          acptPicSignature: this.userPic
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },
    revokeYsfzrConfirm() {
      this.isDoubleClickDisabled = true;
      uni.showModal({
        title: '撤销验收负责人审核',
        placeholderText: '请填写撤销原因',
        editable: true,
        success: (res) => {
          if (res.confirm) {
            this.$commonUnits.postRequest("sbby.maintenancemobilebiz.revokeYsfzrConfirm.mobile", {
              planId: this.planId,
              userId: this.userId,
              remarks: res.content
            }).then(item => {
              uni.showToast({
                title: '撤销成功',
                icon: 'success',
                duration: 2000,
                success: () => {
                  // 延迟返回上一页
                  setTimeout(() => {
                    // 修改一下列表状态显示
                    uni.$emit('updateListData',
                        {
                          planId: this.planId,
                          acptAdminSignature: this.userPic,
                          acptPicSignature: null
                        });
                    //防抖关闭
                    this.isDoubleClickDisabled = false;
                    uni.navigateBack();
                  }, 2000);
                },
              });
            })
          } else if (res.cancel) {
            //防抖关闭
            this.isDoubleClickDisabled = false;
          }
        },
      });
    },
  }
};
</script>

<style>
.container {
  min-height: 100vh;
  background: #f5f7fa;
  padding-bottom: 120rpx;
}

.form-section {
  padding: 20rpx;
}

.form-group {
  background: #ffffff;
  border-radius: 12rpx;
  padding: 24rpx;
  margin-bottom: 20rpx;
}

.form-title {
  font-size: 28rpx;
  font-weight: 500;
  color: #333;
  margin-bottom: 20rpx;
  border-left: 4rpx solid #1890ff;
  padding-left: 12rpx;
}

.form-item {
  display: flex;
  align-items: center;
  padding: 16rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
}

.form-item:last-child {
  border-bottom: none;
}

.label {
  min-width: 160rpx;
  color: #666;
  font-size: 26rpx;
}

.isQualified {
  flex: 1;
  display: flex;
  justify-content: space-between;
}

.value {
  flex: 1;
  color: #333;
  font-size: 26rpx;
}

/* 检查项目样式 */
.check-list {
  margin-top: 10rpx;
}

.check-item {
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f0f0f0;
}

.check-item:last-child {
  border-bottom: none;
}

.check-header {
  display: flex;
  align-items: center;
  margin-bottom: 16rpx;
}

.check-name {
  font-size: 26rpx;
  color: #333;
}

.check-required {
  color: #ff4d4f;
  margin-left: 8rpx;
}

.check-options {
  display: flex;
  padding: 10rpx 20rpx;
  gap: 20rpx;
}

.option {
  flex: 1;
  height: 64rpx;
  min-width: 160rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1rpx solid #d9d9d9;
  border-radius: 6rpx;
  font-size: 26rpx;
  color: #666;
  box-sizing: border-box;
  padding: 0 20rpx;
}

.option.active {
  background: #e6f7ff;
  border-color: #1890ff;
  color: #1890ff;
}

.abnormal-desc {
  margin-top: 16rpx;
  width: 100%;
  height: 120rpx;
  padding: 16rpx;
  box-sizing: border-box;
  border: 1rpx solid #d9d9d9;
  border-radius: 6rpx;
  font-size: 26rpx;
  color: #333;
}

/* 图片上传区域样式 */
.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16rpx;
}

.image-item {
  width: 160rpx;
  height: 160rpx;
  position: relative;
}

.image-item image {
  width: 100%;
  height: 100%;
  border-radius: 6rpx;
}

.delete-btn {
  position: absolute;
  right: -10rpx;
  top: -10rpx;
  width: 40rpx;
  height: 40rpx;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
}

.upload-btn {
  width: 160rpx;
  height: 160rpx;
  border: 1rpx dashed #d9d9d9;
  border-radius: 6rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #999;
}

.plus {
  font-size: 48rpx;
  margin-bottom: 8rpx;
}

.upload-text {
  font-size: 24rpx;
}

/* 在现有样式基础上添加 */
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.quick-action {
  display: flex;
  align-items: center;
  padding: 8rpx 16rpx;
  background: #f6ffed;
  border-radius: 4rpx;
  border: 1rpx solid #52c41a;
  cursor: pointer;
}

.quick-action.is-marked {
  background: #fff1f0;
  border-color: #ff4d4f;
}

.action-text {
  font-size: 24rpx;
  color: #52c41a;
}

.quick-action.is-marked .action-text {
  color: #ff4d4f;
}


.action-icon {
  width: 32rpx;
  height: 32rpx;
  margin-right: 8rpx;
}

/* 图片上传样式 */
.upload-images {
  margin-top: 20rpx;
}

.upload-btn {
  width: 160rpx;
  height: 160rpx;
  background: #fafafa;
  border: 1rpx dashed #d9d9d9;
  border-radius: 8rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-icon {
  font-size: 40rpx;
  color: #999;
  line-height: 1;
  margin-bottom: 4rpx;
}

.upload-text {
  font-size: 24rpx;
  color: #999;
}

.upload-desc {
  font-size: 20rpx;
  color: #999;
  margin-top: 4rpx;
}

.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16rpx;
  margin-top: 16rpx;
}

.image-item {
  position: relative;
  width: 160rpx;
  height: 160rpx;
}

.image-item image {
  width: 100%;
  height: 100%;
  border-radius: 8rpx;
}

.delete-btn {
  position: absolute;
  top: -16rpx;
  right: -16rpx;
  width: 32rpx;
  height: 32rpx;
  line-height: 32rpx;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border-radius: 50%;
  font-size: 24rpx;
}

/* 异常内容区域样式 */
.abnormal-content {
  margin-top: 16rpx;
}

.upload-images {
  margin-top: 16rpx;
}

.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16rpx;
}

.image-item {
  position: relative;
  width: 160rpx;
  height: 160rpx;
}

.image-item image {
  width: 100%;
  height: 100%;
  border-radius: 8rpx;
}

.delete-btn {
  position: absolute;
  top: -16rpx;
  right: -16rpx;
  width: 32rpx;
  height: 32rpx;
  line-height: 32rpx;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border-radius: 50%;
  font-size: 24rpx;
}

.upload-btn {
  width: 160rpx;
  height: 160rpx;
  background: #fafafa;
  border: 1rpx dashed #d9d9d9;
  border-radius: 8rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-icon {
  font-size: 40rpx;
  color: #999;
  line-height: 1;
  margin-bottom: 4rpx;
}

.upload-text {
  font-size: 24rpx;
  color: #999;
}

.upload-desc {
  font-size: 20rpx;
  color: #999;
  margin-top: 4rpx;
}

/* 备注信息样式 */
.remarks {
  width: 100%;
  height: 160rpx;
  padding: 16rpx;
  box-sizing: border-box;
  border: 1rpx solid #d9d9d9;
  border-radius: 6rpx;
  font-size: 26rpx;
  color: #333;
}

/* 底部提交按钮固定定位 */
.footer-submit {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0);
  padding: 20rpx 30rpx;
  z-index: 999;
  display: flex;
  gap: 5px;
}

/* 让页面内容不被底部按钮遮挡 */
.container {
  padding-bottom: 160rpx; /* 根据按钮高度调整 */
}

/* 按钮样式调整 */
.footer-submit button {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  font-size: 32rpx;
  margin: 10rpx 0;
  background: #252b93;
  color: #fff;
  border-radius: 8rpx;
  flex: 1 1 auto;
}

.footer-submit button[disabled] {
  background: #ccc;
}

.footer-submit .revoke {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  font-size: 32rpx;
  margin: 10rpx 0;
  background: #ff0000;
  color: #fff;
  border-radius: 8rpx;
}

.signaturePic {
  width: 100rpx;
  height: 32rpx;
}
</style>